<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>会员添加</title>
    <link href="../../static/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="../../static/css/select.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="../../static/js/jquery.js"></script>
    <script type="text/javascript" src="../../static/js/jquery.idTabs.min.js"></script>
    <script type="text/javascript" src="../../static/js/select-ui.min.js"></script>
    <script type="text/javascript" src="../../static/editor/kindeditor.js"></script>
    <!-- 引入vue -->
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.1"></script>
    <script type="text/javascript">
        KE.show({
            id: 'content7',
            cssPath: './index.css'
        });
    </script>

    <script type="text/javascript">
        $(document).ready(function (e) {
            $(".select1").uedSelect({
                width: 345
            });
            $(".select2").uedSelect({
                width: 167
            });
            $(".select3").uedSelect({
                width: 100
            });

            $("#name").focus(function () {
                $(this).css("background-color", "#0FF")
                var text = $(this).val();
                if (text == "请填写姓名") {
                    $(this).val("");
                }
            });

            $("#name").blur(function () {
                $(this).css("background-color", "#FFF")
                var text = $(this).val();
                if (text == "") {
                    $(this).val("请填写姓名");
                }
            });


        });

        function checkidentity() {
            var id = $("#identity").val();
            var notice2 = $("#notice2");
            var regid = /^[1-9]{1}[0-9]{16}([0-9]|[xX])$/;
            if (regid.test(id) == false) {
                $(notice2).html("身份证输入不合法");
                return false;
            } else {
                $(notice2).html("");
                return true;
            }
        }

        function checkphone() {
            var id = $("#phone").val();
            var notice3 = $("#notice3");
            var regid = /1[3-9]\d{9}/;
            if (regid.test(id) == false) {
                $(notice3).html("电话号码输入不合法");
                return false;
            } else {
                $(notice3).html("");
                return true;
            }
        }

        function checkVipRate() {
            var id = $("#vipRate").val();
            var notice3 = $("#notice4");
            var regid = /\b0(\.\d{1,2})\b/;
            if (regid.test(id) == false) {
                $(notice3).html("折扣输入不合法");
                return false;
            } else {
                $(notice4).html("");
                return true;
            }
        }
    </script>
</head>

<body>

<div class="place">
    <span>位置：</span>
    <ul class="placeul">
        <li>会员管理</li>
        <li>会员添加</li>
    </ul>
</div>

<div class="formbody">


    <div id="usual1" class="usual">

        <div class="itab">
            <ul>
                <li><a href="#tab1" class="selected">添加会员</a></li>

            </ul>
        </div>

        <div id="tab1" class="tabson">

            <div class="formtext">Hi，<b>admin</b>，请填写要添加的会员信息</div>

            <ul class="forminfo">
                <li><label>会员姓名<b>*</b></label><input name="" v-model="vip.customerName" type="text" class="dfinput" value="请填写姓名" id="name"/></li>

                <li><label>性别<b>*</b></label>


                    <div style="padding-top:7px ">
                        <input v-model="vip.gender" value="true" type="radio" name="gender" checked="checked"/>男
                        <input v-model="vip.gender" value="false" type="radio" name="gender"/>女
                    </div>

                </li>

                <li>
                    <div style="position:relative">
                        <label>身份证号码<b>*</b></label>

                        <input name="" v-model="vip.idcard" type="text" class="dfinput" onblur="checkidentity()" id="identity"/>
                    </div>
                    <div id="notice2"
                         style=" font-size:14px; color:red;position:absolute; z-index:1000; margin-top:-30px; margin-left:    450px">
                    </div>
                </li>


                <li>
                    <div>
                        <label>手机号码<b>*</b></label>

                        <input name="" v-model="vip.phone" type="text" class="dfinput" value="" id="phone" onblur="checkphone()"/>
                    </div>
                    <div id="notice3"
                         style=" font-size:14px; color:red;position:absolute; z-index:1000; margin-top:-30px; margin-left:    450px">
                    </div>

                </li>

                <li>
                    <div>
                        <label>折扣<b>*</b></label>

                        <input name="" v-model="vip.vipRate" type="text" class="dfinput" value="" id="vipRate" onblur="checkVipRate()"/>
                    </div>
                    <div id="notice4"
                         style=" font-size:14px; color:red;position:absolute; z-index:1000; margin-top:-30px; margin-left:    450px">
                    </div>

                </li>
                <!--<li><label>备注消息</label>


                    <textarea id="content7" name="content"
                              style="width:700px;height:250px;visibility:hidden;"></textarea>

                </li>-->
                <li><label>&nbsp;</label><input name="" type="submit" class="btn" value="确认" @click="addVip"/></li>
            </ul>

        </div>
    </div>
</div>
<script type="text/javascript">
    var vue = new Vue({
        el: ".formbody",
        data: {
            vip: {
                customerName: '',
                gender: '',
                idcard: '',
                phone: '',
                vipRate: ''
            }
        },
        methods: {
            addVip() {
                this.$http.post("/addVip.do", this.vip).then(
                    function (rs) {
                        if (rs.data) {
                            window.location.href = "vip.html";
                        } else {
                            window.alert("添加失败，请重试");
                        }
                    },
                    function (err) {
                        window.alert("数据请求失败");
                    }
                );
            }
        },
        mounted() {

        }
    })
</script>
</body>

</html>
